﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Image = System.Web.UI.WebControls.Image;

public partial class UserLogin_Leader_LeaderIndex : System.Web.UI.Page
{
    DataClassesDataContext db = new DataClassesDataContext();

    int off = 0;

    string panelStyle = "width:1200px; height:150px; margin-left:150px; margin-right:150px; margin-top:30px;border-radius:10px;";

    string tableOutStyle = "width:1200px;height:130px;margin-top:10px;margin-bottom:10px;";

    string imageStyle = "width:100px;height:100px;margin-left:25px;margin-right:25px;margin-top:10px;margin-bottom:10px;";

    string tableInCellStyle1 = "width:100px;height:50px;";

    string tableInCellStyle2 = "width:450px;height:50px";

    string tableInCellStyle3 = "width:150px;height:50px";

    string tableInCellStyle4 = "width:250px;height:50px;";

    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            string Name = Session["Name"].ToString();

            var projectResults = from r in db.ProjectInfo
                                 select r;

            foreach (var projectResult in projectResults)
            {
                ProjectInfo tmp = (ProjectInfo)projectResult;

                string ProjectName = tmp.ProjectName;
                string Type = tmp.Type;

                string ProjectManager = tmp.ProjectManager;
                string ProjectMember = tmp.ProjectMember;
                string StartEndTime = tmp.StartTime + " -- " + tmp.EndTime;

                CreatePanel(ProjectName, Type, ProjectManager, ProjectMember, StartEndTime);
            }

        }




    }

    protected void CreatePanel(string ProjectName, string Type, string ProjectManager, string ProjectMember, string StartEndTime)
    {
        Panel panel = new Panel();
        InitPanel(panel);
        panel.Attributes.Add("onclick", "window.location.href='/UserLogin/ProjectIndex.aspx?ProjectName=" + ProjectName + "'");//面板点击页面跳转
        panel.Attributes.Add("style", panelStyle);
        panel.BorderWidth = Unit.Pixel(3);
        panel.BorderColor = Color.FromName("#FFCC99");
        panel.BackColor = Color.FromName("#EDEDED");


        PlaceHolder1.Controls.Add(panel);

        TableCell cellProjectName = (TableCell)PlaceHolder1.FindControl("ProjectName" + off);
        cellProjectName.Text = ProjectName;

        TableCell cellType = (TableCell)PlaceHolder1.FindControl("Type" + off);
        cellType.Text = Type;

        TableCell cellProjectManager = (TableCell)PlaceHolder1.FindControl("ProjectManager" + off);
        cellProjectManager.Text = ProjectManager;

        TableCell cellProjectMember = (TableCell)PlaceHolder1.FindControl("ProjectMember" + off);
        cellProjectMember.Text = ProjectMember;

        TableCell cellStartEndTime = (TableCell)PlaceHolder1.FindControl("StartEndTime" + off);
        cellStartEndTime.Text = StartEndTime;

        off = off + 1;
    }

    protected void InitPanel(Panel panel)
    {

        Table tableOut = new Table();
        tableOut.Attributes.Add("style", tableOutStyle);
        //tableOut.BorderWidth = Unit.Pixel(2);


        TableRow tableOutRow = new TableRow();

        TableCell cell1 = new TableCell();
        cell1.Width = Unit.Pixel(130); cell1.Height = Unit.Pixel(130);
        Image IconProject = new Image();
        IconProject.ImageUrl = "~/Pictures/IconProject.png";
        IconProject.Attributes.Add("style", imageStyle);
        cell1.Controls.Add(IconProject);



        TableCell cell2 = new TableCell();
        {
            Table tableIn = new Table();

            TableRow tableInRow1 = new TableRow();

            TableCell cell11 = new TableCell();
            cell11.Text = "项目名称：";
            cell11.Attributes.Add("style", tableInCellStyle1);

            TableCell cell12 = new TableCell();
            cell12.ID = "ProjectName" + off;
            //cell12.BackColor = Color.Yellow;
            cell12.Attributes.Add("style", tableInCellStyle2);

            TableCell cell13 = new TableCell();
            cell13.Text = "项目经理：";
            cell13.Attributes.Add("style", tableInCellStyle3);

            TableCell cell14 = new TableCell();
            cell14.Text = "项目成员：";
            cell14.Attributes.Add("style", tableInCellStyle3);

            TableCell cell15 = new TableCell();
            cell15.Text = "起止时间：";
            cell15.Attributes.Add("style", tableInCellStyle4);


            tableInRow1.Controls.Add(cell11);
            tableInRow1.Controls.Add(cell12);
            tableInRow1.Controls.Add(cell13);
            tableInRow1.Controls.Add(cell14);
            tableInRow1.Controls.Add(cell15);


            TableRow tableInRow2 = new TableRow();

            TableCell cell21 = new TableCell();
            cell21.Text = "项目类别：";
            cell21.Attributes.Add("style", tableInCellStyle1);

            TableCell cell22 = new TableCell();
            cell22.ID = "Type" + off;
            //cell22.BackColor = Color.Yellow;
            cell22.Attributes.Add("style", tableInCellStyle2);

            TableCell cell23 = new TableCell();
            cell23.ID = "ProjectManager" + off;
            //cell23.BackColor = Color.Yellow;
            cell23.Attributes.Add("style", tableInCellStyle3);

            TableCell cell24 = new TableCell();
            cell24.ID = "ProjectMember" + off;
            //cell24.BackColor = Color.Yellow;
            cell24.Attributes.Add("style", tableInCellStyle3);

            TableCell cell25 = new TableCell();
            cell25.ID = "StartEndTime" + off;
            //cell25.BackColor = Color.Yellow;
            cell25.Attributes.Add("style", tableInCellStyle4);

            tableInRow2.Controls.Add(cell21);
            tableInRow2.Controls.Add(cell22);
            tableInRow2.Controls.Add(cell23);
            tableInRow2.Controls.Add(cell24);
            tableInRow2.Controls.Add(cell25);

            tableIn.Rows.Add(tableInRow1);
            tableIn.Rows.Add(tableInRow2);


            cell2.Controls.Add(tableIn);
        }



        tableOutRow.Cells.Add(cell1);
        tableOutRow.Cells.Add(cell2);
        tableOut.Rows.Add(tableOutRow);


        panel.Controls.Add(tableOut);
    }
}